var home = require("../../utils/util.js");
var url = home.home;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active:0,
    page:1,
    memberProjectId:'',
    orderProjectId:0,
    show1:2,
    show2:2
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      orderProjectId:options.orderProjectId
    })
  },

  //获取项目列表
  getProjectList(){
    let that = this;
    wx.request({
      url: url + 'app/listMemberProjectShopAndServe',
      data:{
        pageNo:that.data.page,
        storeId:home.getKey('storeId'),
        orderProjectId:that.data.orderProjectId,
      },
      method: 'POST',
      header: {
        "content-type": "application/json", // 默认
      },
      success:function (res) {
        let show1 = 1;
        let show2 = 1;
        if (res.data.result.serveList.length == 0) {
          show1 = 2;
        }
        if (res.data.result.commodityList.length == 0) {
          show2 = 2;
        }
        that.setData({
          serveList:res.data.result.serveList,
          commodityList:res.data.result.commodityList,
          show1:show1,
          show2:show2
        })
      }
    })
  },

  onChange(e) {
    this.setData({
      active:e.detail.index,
      page:1
    });
    this.getProjectList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getProjectList();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let page = this.data.page;
    this.setData({page:++page});
    this.getProjectList();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})